<template>
  <div class="searchhot-content">
    <div class="search-box">
      <div class="searchhot-top">
        <search
          @textChange="textChange"
          v-bind:show="true"
          ref="search"
        />
      </div>
      <div
        class="right"
        @click="searchBtn"
      >搜索</div>
    </div>
    <div class="search-hot_bd">
      <span class="hot-span">热门搜索</span>
      <div class="hot-content">
        <div
          v-for="(item,index) in tagArr"
          :key="index"
          @click="linkto(item)"
          class="hot-content-item"
        >
          <span>{{item}}</span>
        </div>
      </div>
    </div>

  </div>

</template>
<script>
import CONSTANT from "../../../wechat/static/constant/urlconstant";
import common from "../../../wechat/static/common/common";
import search from "@/components/common/search.vue";
export default {
  name: "searchhot",
  components: {
    search
  },
  data() {
    return {
      tagArr: [],
      searchText: ""
    };
  },
  mounted() {
    this.getTagList();
  },
  methods: {
    textChange(val) {
      this.searchText = val;
    },
    searchBtn() {
      this.$router.push("/searchResult?text=" + this.searchText);
    },
    linkto(val) {
       this.$router.push("/searchResult?text=" + val);
    },
    getTagList() {
      let url = CONSTANT.LIST.hotTagList;
      common.get(url, "", res => {
        if (res.code == 200) {
          this.tagArr = res.data.bussData;
        }
      });
    }
  }
};
</script>
<style lang="less">
.searchhot-content {
  position: relative;
  overflow: hidden;
  .search-box {
    background-color: rgba(126, 86, 198, 1);
    width: 100%;
    height: 0.77rem;
    display: flex;
    align-items: center;
    .searchhot-top {
      position: relative;
      margin-left: 0.7rem;
      height: 0.6rem;
      display: flex;
      align-items: center;
    }
    .right {
      position: absolute;
      right: 0.28rem;
      height: 0.28rem;
      font-size: 0.3rem;
      font-family: PingFang-SC-Medium;
      font-weight: 500;
      color: rgba(255, 255, 255, 1);
      line-height: 0.28rem;
    }
  }
  .search-hot_bd {
    // position: absolute;
    width: 100%;
    background: rgba(255, 255, 255, 1);
    .hot-span {
      display: block;
      margin: 0 0 0.4rem 0.4rem;
      padding-top: 0.44rem;
      height: 0.25rem;
      font-size: 0.26rem;
      font-family: PingFang-SC-Regular;
      font-weight: 400;
      color: rgba(126, 86, 198, 1);
      line-height: 0.38rem;
      margin-bottom: 0.4rem;
    }
    .hot-content {
      display: inline-block;
      padding: 0 0.4rem;
      .hot-content-item {
        display: inline-block;
        margin-right: 0.37rem;
        word-spacing: normal;
        word-break: normal;
        box-sizing: border-box;
        padding: 0 0.15rem;
        height: 0.64rem;
        background: rgba(245, 245, 245, 1);
        border-radius: 0.1rem;
        font-size: 0.28rem;
        font-family: PingFang-SC-Medium;
        font-weight: 500;
        color: rgba(102, 102, 102, 1);
        line-height: 0.64rem;
        text-align: center;
        margin-bottom: 0.4rem;
      }
    }
  }
}
</style>
